var lon = -74.08943;
var lat = 4.64491;
var zoom = 0;
var map;
var layer7;
var markers;
var calculateOffset;
var vlayer;
var bounds;

function init(){
    
    //$('showLeftColumn').hide();
    
    bounds = new OpenLayers.Bounds(-74.11318,4.61924,-74.06911,4.66927);

    vlayer = new OpenLayers.Layer.Vector( "Editable" );

    map = new OpenLayers.Map('map', 
    {controls: [], 
        maxExtent: bounds, 
        maxResolution: "auto", 
        maxZoomLevel: 8, 
        tileSize: new OpenLayers.Size(256,256)});
    map.addControl(new OpenLayers.Control.PanZoomBar());
    map.addControl(new OpenLayers.Control.MouseDefaults());
    map.addControl(new OpenLayers.Control.KeyboardDefaults());
    //map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
    map.addControl(new OpenLayers.Control.MousePosition({'div':OpenLayers.Util.getElement('coordDiv')}));
    map.addControl(new OpenLayers.Control.OverviewMap({'div':OpenLayers.Util.getElement('overviewDiv')}));
    map.addControl(new OpenLayers.Control.NavToolbar());
    map.addControl(new OpenLayers.Control.EditingToolbar(vlayer));

    //                map = new OpenLayers.Map( 'map', { controls: [new OpenLayers.Control.PanZoom()], maxZoomLevel: 6 } );                //http://localhost/cgi-bin/mapserv?map=c:/ms4w/Apache/htdocs/Bomberos/sun1.map&SERVICE=WMS&REQUEST=GetMap&version=1.1.1&layers=Manzanas&styles=default&srs=EPSG:21897&bbox=994844.144982932,1001052.2109485184,1002470.5077450916,1008815.6327788776&width=700&height=800&format=image/png
    layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
    "http://labs.metacarta.com/wms/vmap0",
    {layers: 'basic'});

    /*
                layer1 = new OpenLayers.Layer.WMS( "Localidad", 
                "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'Teusaquillo', styles: 'default', format: 'image/png'} );
                layer2 = new OpenLayers.Layer.WMS( "Barrios", 
                "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'Barrios', styles: 'default', format: 'image/png', transparent:true} );
                layer3 = new OpenLayers.Layer.WMS( "Sitios de Interes", 
                "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'sitios_de_interes', styles: 'default', format: 'image/png', transparent:true} );
                layer4 = new OpenLayers.Layer.WMS( "Construcciones", 
                "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'Construcciones', styles: 'default', format: 'image/png', transparent:true} );
                layer5 = new OpenLayers.Layer.WMS( "Malla Vial", 
                "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'Malla_vial', styles: 'default', format: 'image/png', transparent:true} );
                layer6 = new OpenLayers.Layer.WMS( "Predios", 
                "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'Predios', styles: 'default', format: 'image/png', transparent:true} );
     */
    layer7 = new OpenLayers.Layer.WMS( "Manzanas", 
    "http://192.168.0.2/cgi-bin/mapserv?", {map: 'c:/ms4w/Apache/htdocs/Bomberos/bomberos.map', SERVICE:'WMS', layers: 'Teusaquillo,Barrios,sitios_de_interes,Malla_vial,Manzanas,Predios,Construcciones', styles: 'default', format: 'image/png'} );
    //                map.addLayer(layer1);
    //                map.addLayer(layer2);
    //                map.addLayer(layer3);
    //                map.addLayer(layer4);
    //                map.addLayer(layer5);
    //                map.addLayer(layer6);
    map.addLayer(layer);
    map.addLayer(vlayer);
    markers = new OpenLayers.Layer.Markers( "Markers" );
    map.addLayer(markers);
    size = new OpenLayers.Size(20,20);
    calculateOffset = function(size) {
        return new OpenLayers.Pixel(-(size.w/2), -size.h); };

    //map.addControl(new OpenLayers.Control.LayerSwitcher());
    //var panel = new OpenLayers.Control.NavToolbar({'div':OpenLayers.Util.getElement('paneldiv')});
    //map.addControl(panel);
    map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            
}
function recenter(lon, lat){
    var icon = new OpenLayers.Icon(
    'http://boston.openguides.org/markers/ORANGE.png',
    size, null, calculateOffset);
    markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(lon,lat), icon));
    map.setCenter(new OpenLayers.LonLat(lon, lat));
}
